package com.yanqu.road.server.cmd.mogulbirthday;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.bossbirthday.MogulBirthdayProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.mogulbirthday.MogulBirthdayMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_MOGUL_BIRTHDAY_BEST_DECORATION_UPLOAD, desc = "最高称号上传")
public class CrossMogulUploadBestDecorationCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        MogulBirthdayProto.MogulBirthdayUploadBestDecorationRespMsg respMsg = MogulBirthdayProto.MogulBirthdayUploadBestDecorationRespMsg.parseFrom(packet.getBytes());
        for (MogulBirthdayProto.MogulBirthdayBestTitleTemp bestTitleTemp : respMsg.getBestList()) {
            MogulBirthdayMgr.getBestDecorationMap().put(bestTitleTemp.getUserId(), bestTitleTemp.getDecorationId());
            if(bestTitleTemp.hasBaseInfo()){
                CrossUserMgr.updateUserBaseInfo(bestTitleTemp.getUserId(), PlayerBasePb.parseToUserBaseInfo(bestTitleTemp.getBaseInfo()));
            }
        }
    }

    @Override
    public void sendData() {

    }
}
